
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using WorkOrder.Models;

namespace WorkOrder.Interfaces
{
    public interface IWorkOrderService
    {
          // 基础操作
        Task<工单主表> CreateWorkOrderAsync(工单主表 workOrder, string processId);
        Task<工单主表> GetWorkOrderByIdAsync(string workOrderId);
        Task<IEnumerable<工单主表>> GetChildWorkOrdersAsync(string parentWorkOrderId);
        Task UpdateWorkOrderAsync(工单主表 workOrder);
        Task DeleteWorkOrderAsync(string workOrderId,string operatorId, string comment);

        // 状态管理
        Task CloseWorkOrderAsync(string workOrderId, string operatorId, string comment);
        Task ReopenWorkOrderAsync(string workOrderId, string operatorId, string comment);
        Task<BootstrapBlazor.Components.QueryData<TModel>> QueryTable<TModel> (BootstrapBlazor.Components.QueryPageOptions option) where TModel : class, new();
        // 分派管理
        Task AssignWorkOrderAsync(string workOrderId,  IEnumerable<string> assigneeIds, string operatorId, string comment);
        Task TransferWorkOrderAsync(string workOrderId, string fromUserId, string toUserId, string operatorId, string comment);
        Task<List<工单主表>>  BatchCreateWorkOrdersAsync(string templateId,List<Dictionary<string, object>> workOrders, string? title, string? description, string 创建人ID,string 流程ID);

        Task CompleteWorkOrderAndDeductAsync(string workOrderId, string operatorId, string comment);

        Task   RechargeUserBalanceAsync(string userId, decimal amount, string     operatorId,string relatedBusinessId = null, string customRemark = null);
        Task   ChangeAssigneeAsync(string workOrderId,IEnumerable<string> newAssigneeIds, string operatorId, string comment);
        Task<List<模板字段表>> GetTemplates(string 模板ID);
 

        Task<List<工单全信息视图>> GetWorkOrdersAsync();

        Task<IEnumerable<工单操作日志表>> GetWorkOrderslog(string workOrderID);

        Task<List<资金流水表>> GetFlowforTime(DateTime startDate, DateTime endDate);
        Task<List<当前分派视图>> GetHandler(string workOrderID);


        Task<工单模板表?> GetTemplateByIdAsync(string templateId);
        Task<List<用户账户余额表>> GetRecharge();
        Task<List<资金流水表>> GetFlow(string UserName);


        Task<List<工单模板表>> GetTemplateList();
        Task<List<流程配置表>> GetProcessList(string? 流程ID=null);


        Task<工单流程实例表> GetProcessInstanceByWorkOrderIdAsync(string workOrderId);
        工单流程实例表 GetProcessInstanceByWorkOrderId(string workOrderId);

        Task<流程节点表?> GetRoute(string 节点ID);

        // Task TransitionToNextNodeAsync(string workOrderId, string operatorId);
        Task  TransitionToNextNodeAsync(string workOrderId, string operatorId,bool isBatch = true);
        Task AddCommentAsync(CommentType commentType, string workOrderId, string operatorId, string text);


        Task<List<工单全信息视图>> GetWorkOrdersForUserAsync(string user, WorkOrderStatus? workOrderStatu=null);

        Task<List<工单全信息视图>> GetWorkOrdersForUserCompletedAsync(string user);

          Task<List<工单全信息视图>> GetWorkOrdersForMeAsync(string user);

          Task<List<工单全信息视图>> GetWorkOrdersForAuditorAsync(List<string>  roles);
  
          Task AddFlieAsync(工单附件表  工单附件表); 
          Task DeleteFlieAsync(string fileName,string  TicketID);
    }
}